/**
 * @description 单选框组件
 * @author 大肘子
 */

import React, { FC } from "react";
import { QuestionRadioType, QuestionRadioDefaultValue, optionType } from "./type";
import { Typography, Radio, Space } from "antd";
const { Title } = Typography;
const QuestionRadioComponent: FC<QuestionRadioType> = (props) => {
  const { title = "", options = [], isvertical = false, defaultselected = "" } = { ...QuestionRadioDefaultValue, ...props };
  return (
    <>
      <Title style={{ fontSize: "23px" }}>{title}</Title>
      <Radio.Group value={defaultselected}>
        <Space direction={isvertical ? "vertical" : "horizontal"}>
          {options.map((item: optionType) => {
            return (
              <Radio key={item.value} value={item.value}>
                {item.text}
              </Radio>
            );
          })}
        </Space>
      </Radio.Group>
    </>
  );
};

export default QuestionRadioComponent;
